<?php
if(isset($_GET['id'])) 
{
// if id is set then get the file with the id from database
/* Connect to MySQL Database */
$connect = mysql_connect("127.0.0.1","root","!@#098asd");
if (!$connect)
  {
  die('Could not connect: ' . mysql_error());
  }
/*Select the DB */
  mysql_select_db("UPLOAD", $connect);

$id    = $_GET['id'];
$query = "SELECT name, type, size, content " .
         "FROM upload WHERE id = '$id'";

$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);

header("Content-length:$size");
header("Content-type:$type");
header("Content-Disposition: attachment; filename=$name");
stripcslashes($name);
stripslashes($content);
echo $content;
}
?>